package com.zbkj.crmeb.store.model;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zbkj.crmeb.store.FeatureBaseDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 订单表
 * </p>
 *
 * @author Mr.Zhang
 * @since 2020-05-28
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("eb_store_order")
@ApiModel(value="StoreOrder对象", description="订单表")
public class StoreOrder extends FeatureBaseDO implements Serializable {

    private static final long serialVersionUID=1L;

    @ApiModelProperty(value = "订单ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 不可生成下划线
     * auth: dai
     */
    @ApiModelProperty(value = "订单号")
    private String orderId;

    @ApiModelProperty(value = "商品名称")
    @TableField(exist = false)
    private String productName;

    @ApiModelProperty(value = "用户id")
    private Integer uid;

    @ApiModelProperty(value = "团长id")
    private Integer leaderId;

    @ApiModelProperty(value = "用户姓名")
    private String realName;

    @ApiModelProperty(value = "用户电话")
    private String userPhone;

    /**
     * 区域类型: 1 国内，2 港澳，3 海外
     */
    @ApiModelProperty(value = "区域类型")
    private Integer areaType;

    @ApiModelProperty(value = "详细地址")
    private String userAddress;

    @ApiModelProperty(value = "运费金额")
    private BigDecimal freightPrice;

    @ApiModelProperty(value = "订单商品总数")
    private Integer totalNum;

    @ApiModelProperty(value = "订单总价")
    private BigDecimal totalPrice;

    // todo 价格计算有问题
    @ApiModelProperty(value = "拼团价")
    @TableField(exist = false)
    private BigDecimal packagePrice;

    @ApiModelProperty(value = "邮费")
    private BigDecimal totalPostage;

    @ApiModelProperty(value = "实际支付金额")
    private BigDecimal payPrice;

    @ApiModelProperty(value = "支付邮费")
    private BigDecimal payPostage;

    @ApiModelProperty(value = "抵扣金额")
    private BigDecimal deductionPrice;

    @ApiModelProperty(value = "优惠券id")
    private Integer couponId;

    @ApiModelProperty(value = "优惠券金额")
    private BigDecimal couponPrice;

    @ApiModelProperty(value = "支付状态")
    private Boolean paid;

    @ApiModelProperty(value = "支付时间")
    private Date payTime;

    @ApiModelProperty(value = "支付方式")
    private String payType;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "创建人名称")
    private String createName;

//    @ApiModelProperty(value = "创建时间") todo ZL
//    private String day;

    @ApiModelProperty(value = "订单状态（-1 : 申请退款 -2 : 退货成功 0：待发货；1：待收货；2：已收货，待评价；3：已完成；）")
    private Integer status;

    @ApiModelProperty(value = "0 未退款 1 申请中 2 已退款 3 补偿性退款 ")
    private Integer refundStatus;

    @ApiModelProperty(value = "退款图片")
    private String refundReasonWapImg;

    @ApiModelProperty(value = "退款用户说明")
    private String refundReasonWapExplain;

    @ApiModelProperty(value = "退款时间")
    private Date refundReasonTime;

    @ApiModelProperty(value = "前台退款原因")
    private String refundReasonWap;

    @ApiModelProperty(value = "不退款的理由")
    private String refundReason;

    @ApiModelProperty(value = "退款金额")
    private BigDecimal refundPrice;

    @ApiModelProperty(value = "快递名称/送货人姓名")
    private String deliveryName;

    @ApiModelProperty(value = "发货类型")
    private String deliveryType;

    @ApiModelProperty(value = "快递单号/手机号")
    private String deliveryId;

    @ApiModelProperty(value = "积分倍数")
    private BigDecimal integralMultiples;

    @ApiModelProperty(value = "消费赚取积分")
    private Integer gainIntegral;

    @ApiModelProperty(value = "当前订单是否启用积分抵扣(0否 1是)")
    private Integer enableIntegral;

    @ApiModelProperty(value = "使用积分")
    private Integer useIntegral;

    @ApiModelProperty(value = "给用户退了多少积分")
    private Integer backIntegral;

    @ApiModelProperty(value = "备注")
    private String mark;

    @ApiModelProperty(value = "是否删除")
    private Boolean isDel;

    @ApiModelProperty(value = "唯一id(md5加密)类似id")
    @TableField(value = "`unique`")
    private String unique;

    @ApiModelProperty(value = "管理员备注")
    private String remark;

    @ApiModelProperty(value = "商户ID")
    private Integer merId;

    private Integer isMerCheck;

    @ApiModelProperty(value = "拼团商品id0一般商品")
    private Integer combinationId;

    @ApiModelProperty(value = "拼团id 0没有拼团")
    private Integer pinkId;

    @ApiModelProperty(value = "觅览的成本价")
    private BigDecimal cost;

    @ApiModelProperty(value = "第三方推送的成本价")
    private BigDecimal sourceCost;

    @ApiModelProperty(value = "秒杀商品ID")
    private Integer seckillId;

    @ApiModelProperty(value = "砍价id")
    private Integer bargainId;

    @ApiModelProperty(value = "核销码")
    private String verifyCode;

    @ApiModelProperty(value = "门店id")
    private Integer storeId;

    @ApiModelProperty(value = "配送方式 1=快递 ，2=门店自提")
    private Integer shippingType;

    @ApiModelProperty(value = "店员id")
    private Integer clerkId;

    @ApiModelProperty(value = "支付渠道(0微信公众号1微信小程序)")
    private Integer isChannel;

    @ApiModelProperty(value = "消息提醒")
    private Boolean isRemind;

    @ApiModelProperty(value = "后台是否删除")
    private Boolean isSystemDel;

    @ApiModelProperty(value = "订单推送状态（0 : 未推送 1 : 推送成功 2：推送失败；）")
    private Integer pushStatus;
    
    @ApiModelProperty(value = "订单推送吉客云状态（0 : 未推送 1 : 推送成功 2：推送失败；）")
    private String pushJkyStatus;

    @ApiModelProperty(value = "订单推送返回信息")
    private String pushMessage;

    @ApiModelProperty(value = "收货人所在省")
    private String province;
    @ApiModelProperty(value = "收货人所在市")
    private String city;
    @ApiModelProperty(value = "收货人所在区")
    private String district;
    @ApiModelProperty(value = "收货人详细地址")
    private String detail;
    @ApiModelProperty(value = "收货人身份证号")
    private String idCard;

    @ApiModelProperty(value = "订单来源（1: 寻物 2：天猫 9: 手动推送)")
    private Integer source;

    @ApiModelProperty(value = "第三方订单号")
    private String outOrderId;
    
    @ApiModelProperty(value = "面单地址")
    private String expressUrl;
    
    @ApiModelProperty(value = "回调失败次数")
    private Integer backCount;
    
    @ApiModelProperty(value = "支付回调状态")
    private Boolean backStatus;
    
    @ApiModelProperty(value = "下单支付参数")
    private String payParam;
    
    @ApiModelProperty(value = "支付回调参数")
    private String backParam;
    
    @ApiModelProperty(value = "分账回调参数")
    private String transBackParam;

    @ApiModelProperty(value = "用户ids")
    @TableField(exist = false)
    private List<Integer> uidList;

    @ApiModelProperty(value = "自提联系方式")
    private String toPhone;

    @ApiModelProperty( hidden= true )
    @TableField(exist = false)
    private String where;

    @ApiModelProperty(value = "是否异常订单（0正常 1异常）")
    private Integer abnormal;

    @ApiModelProperty(value = "推送单号",hidden = true)
    @TableField(exist = false)
    private String pushOrderNo;

    @ApiModelProperty(value = "收款凭证")
    private String receiptVoucher;

    @ApiModelProperty(value = "会员优惠价格")
    private BigDecimal vipReducePrice;

    @ApiModelProperty(value = "批采单id")
    private Integer pickingId;

    @ApiModelProperty(value = "拼团活动id")
    private Integer activityGroupId;

    @ApiModelProperty(value = "真拼团活动id，上面那字段不是是啥玩意")
    private Integer activityId;

    @ApiModelProperty(value = "外部订单来源（1: 吉客云 2：海带 3: 天猫)")
    private Integer outOrderSource;

    @ApiModelProperty(value = "发货回传flg")
    private Integer deliverFlg;

    @ApiModelProperty(value = "发货回传信息")
    private String deliveryNoticeMsg;

    @ApiModelProperty(value = "支付单号")
    private String payNo;

    @ApiModelProperty(value = "支付人姓名")
    private String payName;

    @ApiModelProperty(value = "扩展字段")
    private String feature;

    @Override
    protected void resetFeature() {
        feature = JSONObject.toJSONString(getFeatureMap());
    }

    @Override
    protected String getFeatureString() {
        return feature;
    }
}
